package com.qingcloud.adminbackend.entity.usergroup;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * <p>
 * 用户组分页查询条件
 * </p>
 *
 * @author wangjinnan
 * @since 2018-11-15
 */
@Data
public class SysUsergroupPageParam {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "所属客户ID", example = "f4c09b0afe174c5cb6875004276049a0")
    private String orgId;

    @ApiModelProperty(value = "用户组名称", example = "研发组")
    private String name;

    @ApiModelProperty(value = "姓名", example = "老王")
    private String fullName;

    @ApiModelProperty(value = "手机号", example = "1312312")
    private String mobileno;

    @ApiModelProperty(value = "登录名", example = "admin")
    private String userName;

    @ApiModelProperty(value = "应用ID", example = "1")
    private Integer appId;

    @ApiModelProperty(value = "当前第几页，从1开始", example = "1")
    private Integer currentPage;

    @ApiModelProperty(value = "每页多少条", example = "10")
    private Integer perPage;

    @ApiModelProperty(value = "用户组ID列表", hidden = true)
    private List<String> idList;

    @ApiModelProperty(value = "用户可读可写客户ID列表", hidden = true)
    private List<String> orgIdList;

    @ApiModelProperty(value = "mybatis plus分页对象", hidden = true)
    private Page page;

    public String getName() {
        if (!StringUtils.isEmpty(name) && name.trim().length() > 0) {
            return "%" + name + "%";
        }
        return null;
    }

    public String getFullName() {
        if (!StringUtils.isEmpty(fullName) && fullName.trim().length() > 0) {
            return "%" + fullName + "%";
        }
        return null;

    }

    public String getMobileno() {
        if (!StringUtils.isEmpty(mobileno) && mobileno.trim().length() > 0) {
            return "%" + mobileno + "%";
        }
        return null;
    }

    public String getUserName() {
        if (!StringUtils.isEmpty(userName) && userName.trim().length() > 0) {
            return "%" + userName + "%";
        }
        return null;
    }

    public Page getPage() {
        if (currentPage != null && perPage != null) {
            return new Page(currentPage, perPage);
        }
        return null;
    }
}
